<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        点击发送验证码
    </div>
    <input type="number">
    <button>
        点击发送验证码
    </button>



</body>

<script>
    var buttomDom = document.querySelector("button");
    var time = 10;
    buttomDom.onclick = function () {
        buttomDom.disabled = true;
        console.log("点击了，发送验证码");
        buttomDom.innerText = time;//将按钮文本设置为倒计时
        var interval = setInterval(function () {
            time--;
            console.log(time);
            buttomDom.innerText = time;
            if (time == 0) {
                buttomDom.disabled = false;
                buttomDom.innerText = "点击发送验证码";
                time = 10;
                clearInterval(interval);
            }
        }, 1000);
    };
</script>

</html>